﻿using System.Collections;
using System.Collections.Generic;
using JetBrains.Annotations;
using UnityEngine;

public class MainGPUInstance : MonoBehaviour
{
    public Mesh mesh;
    public Material material;

    public Mesh mesh2;
    public Material material2;

    private void LateUpdate()
    {
        //Test1
        Matrix4x4[] matrixs_0 = new Matrix4x4[2048];
        for (int i = 0; i < 2048; i++)
        {
            matrixs_0[i] = Matrix4x4.identity;
            matrixs_0[i].m03 = i * 1.1f;
        }
        Graphics.DrawMeshInstanced(mesh, 0, material, matrixs_0, 3);


        Matrix4x4[] matrixs_1 = new Matrix4x4[2048];
        for (int i = 0; i < 2048; i++)
        {
            matrixs_1[i] = Matrix4x4.identity;
            matrixs_1[i].m03 = i * 1.1f;
            matrixs_1[i].m13 = 3f;
        }
        Graphics.DrawMeshInstanced(mesh, 0, material, matrixs_1, 2);

        Matrix4x4[] matrixs_2 = new Matrix4x4[2048];
        for (int i = 0; i < 2048; i++)
        {
            matrixs_2[i] = Matrix4x4.identity;
            matrixs_2[i].m03 = i * 1.1f;
            matrixs_2[i].m13 = 6f;
        }
        Graphics.DrawMeshInstanced(mesh2, 0, material2, matrixs_2, 5);
    }
}
